package com.quick.common.utils;


import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;


public class Md5 {
    /**
     * MD5加密
     *
     * @param dataStr 数据
     * @return String
     */
    public static String md5(String dataStr) {
        MessageDigest m = null;
        try {
            m = MessageDigest.getInstance("MD5");
            m.update(dataStr.getBytes(StandardCharsets.UTF_8));
            byte[] s = m.digest();
            StringBuilder result = new StringBuilder();
            for (byte b : s) {
                result.append(Integer.toHexString((0x000000FF & b) | 0xFFFFFF00).substring(6));
            }
            return result.toString();
        } catch (Exception ignored) {
            return "";
        }
    }

}
